package com.szholly.plug.cms.notice;

import java.util.Date;

import com.szholly.plug.cms.entity.notice.SystemNoticeRow;
import com.szholly.plug.cms.entity.notice.SystemNoticeTable;
import com.szholly.utils.common.notice.ISystemNotice;
import com.szholly.plug.safe.entity.user.UserEntity;

/**
 * 系统通知接口
 */
public class SystemNoticeSendTool implements ISystemNotice {

	@Override
	public boolean sendNotice(Object form, Object to, String subject,
			String body) {
		UserEntity formUser = (UserEntity)form;
		UserEntity toUser = (UserEntity)to;
		
		if(toUser==null){
			return false;
		}
		
		SystemNoticeRow noticeRow = new SystemNoticeRow();
		noticeRow.setDxtz("0");
		noticeRow.setFsnr(body);
		if(formUser==null){
			noticeRow.setFsr("系统自动发送");
		}else{
			noticeRow.setFsr(formUser.getUserID());
		}
		noticeRow.setFssj(new Date());
		noticeRow.setJsr(toUser.getUserID());
		SystemNoticeTable.getSingleRef().save(noticeRow);
		return true;
	}
}